//
//  ViewController.m
//  UI_FrameAndBounds
//
//  Created by Rain on 16/6/4.
//  Copyright © 2016年 Rain. All rights reserved.
//

#import "ViewController.h"

#define kFrameNSLog(VIEW) NSLog(@"VIEW frame: x: %lf, y: %lf, w: %lf, h: %lf", VIEW.frame.origin.x, VIEW.frame.origin.y, VIEW.frame.size.width, VIEW.frame.size.height);


@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self createSubViews];
    
}

- (void)createSubViews {
    // 创建视图1, 添加到self.view上
    UIView *view1 = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 200, 300)];
    view1.backgroundColor = [UIColor blackColor];
    [self.view addSubview:view1];
    [view1 release];
    
    
    // 创建视图2, 添加到视图1上.
    UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 50)];
    view2.backgroundColor = [UIColor greenColor];
    [view1 addSubview:view2];
    [view2 release];
    
    NSLog(@"view1 bounds: x: %lf, y: %lf, w: %lf, h: %lf", view1.bounds.origin.x, view1.bounds.origin.y, view1.bounds.size.width, view1.bounds.size.height);
    
    //改变view1的bounds的origin, 改变了它的子视图位置
    view1.bounds = CGRectMake(50, 30, 200, 300);
    
    // 改变view1的bounds的size, 改变了它自身在父视图的位置, 影响到了它的frame.
    view1.bounds = CGRectMake(0, 0, 300, 400);
    
    kFrameNSLog(view1);
    kFrameNSLog(view2);
    
    
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
